<%@ page pageEncoding="UTF-8"%>
<%@ include file="../commons/head.jsp"%>
<link rel="stylesheet" href="${ctxStatic}/css/contractEdit/styles.css">
<title>合同删除</title>
<head>
<script type="text/javascript" src="${ctxStatic}/js/fileupload/vendor/jquery.ui.widget.js"></script>
<script type="text/javascript" src="${ctxStatic}/js/fileupload/load-image.min.js"></script>
<script type="text/javascript" src="${ctxStatic}/js/fileupload/canvas-to-blob.min.js"></script>
<script type="text/javascript" src="${ctxStatic}/js/fileupload/jquery.blueimp-gallery.min.js"></script>
<script type="text/javascript" src="${ctxStatic}/js/fileupload/jquery.iframe-transport.js"></script>
<script type="text/javascript" src="${ctxStatic}/js/fileupload/jquery.fileupload.js"></script>
<script type="text/javascript" src="${ctxStatic}/js/fileupload/jquery.fileupload-process.js"></script>
<script type="text/javascript" src="${ctxStatic}/js/fileupload/jquery.fileupload-validate.js"></script>
<script type="text/javascript" src="${ctxStatic}/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="${ctxStatic}/js/bootstrap-datetimepicker.zh-CN.js"></script>
<style type="text/css">
</style>
</head>
<body onload="loadMsg(${id})">
	<div class="htedit">
		<div class="container-fluid">
			<h3>合同删除</h3>
			<form id="form" class="form-horizontal"
				action="${ctx}/contract/save1" method="post"  autocomplete="off">
				<input style="display: none;" id="id" name="id"/><!-- 人的id -->
				<input style="display: none;" id="contractId" name="contractId"/><!-- 合同id -->
				<div class="form-group" style="width: 420px;float: left;">
					<label for="customerPhone" class="col-md-3 control-label" style="width:100px;margin-left: 20px;">手机号码：</label>
					<div class="col-md-2">
						<input id="customerPhone" name="customerPhone"
							class="form-control isRemove" style="width: 180px;height:26px;" type="text"
							value="" maxlength="11" readonly="readonly"  required/>
					</div>
					<div class="col-md-3" id="customerPhoneErr">
						<label class="error"> </label>
					</div>
				</div>
				<div class="form-group" style="width: 420px;float: left;">
					<label for="customerName" class="col-md-3 control-label" style="width:100px;margin-left: 20px;">客户姓名：</label>
					<div class="col-md-2">
						<input id="customerName" name="customerName"
							class="form-control isRemove" style="width: 180px;height:26px;" type="text"
							value="" maxlength="11" readonly="readonly" required/>
					</div>
					<div class="col-md-3" id="customerNameErr">
						<label class="error"> </label>
					</div>
				</div>
				<div class="form-group">
					<label for="registerAdd" class="col-md-3 control-label" style="width:100px;margin-left: 20px;">户口所在地：</label>
					<div class="col-md-2">
						<input id="registerAdd" name="registerAdd"
							class="form-control isRemove" style="width: 570px;height:26px;" type="text"
							value="" maxlength="11" readonly="readonly" required/>
					</div>
					<div class="col-md-3" id="registerAddErr">
						<label class="error"></label>
					</div>
				</div>
				<div class="form-group">
					<label for="perAdd" class="col-md-3 control-label" style="width:100px;margin-left: 20px;">履约地址：</label>
					<div class="col-md-8">
						<input id="perAdd" name="perAdd"
							class="form-control isRemove" style="width: 570px;height:26px;" type="text"
							value="" maxlength="11" readonly="readonly" required/>
					</div>
					<div class="col-md-2" id="perAddErr">
						<label class="error">(信函地址)</label>
					</div>
				</div>
				<div class="form-group" style="width: 420px;float: left;">
					<label for="cardId" class="col-md-3 control-label" style="width:100px;margin-left: 20px;">身份证：</label>
					<div class="col-md-2">
						<input id="cardId" name="cardId"
							class="form-control isRemove" style="width: 180px;height:26px;" type="text"
							value="" maxlength="11" readonly="readonly" required/>
					</div>
					<div class="col-md-3" id="cardIdErr">
						<label class="error"> </label>
					</div>
				</div>
				<div class="form-group" style="width: 420px;float: left;">
					<label for="emerContact" class="col-md-3 control-label" style="width:100px;margin-left: 20px;">紧急联系方式：</label>
					<div class="col-md-2">
						<input id="emerContact" name="emerContact"
							class="form-control isRemove" style="width: 180px;height:26px;" type="text"
							value="" maxlength="11" readonly="readonly" required/>
					</div>
					<div class="col-md-3" id="emerContactErr">
						<label class="error"> </label>
					</div>
				</div>
				<div class="form-group" style="width: 420px;float: left;">
					<label for="origin" class="col-md-3 control-label" style="width:100px;margin-left: 20px;">籍贯：</label>
					<div class="col-md-2">
						<input id="origin" name="origin"
							class="form-control isRemove" style="width: 180px;height:26px;" type="text"
							value="" maxlength="11" readonly="readonly" required/>
					</div>
					<div class="col-md-3" id="originErr">
						<label class="error"> </label>
					</div>
				</div>
				<div class="form-group" style="width: 420px;float: left;">
					<label for="marriage" class="col-md-3 control-label" style="width:100px;margin-left: 20px;">婚姻状况：</label>
					<div class="col-md-2">
						<select id="marriage" name="marriage" class="easyui-combobox" style="width: 180px;height:26px;" required readonly="readonly" editable="false" panelHeight="auto">
							
							<option value="0">未婚</option>
							<option value="1">已婚</option>
						</select>
					</div>
					<div class="col-md-3" id="marriageErr">
						<label class="error"></label>
					</div>
				</div>
				<div class="form-group" style="width: 420px;float: left;">
					<label for="sex" class="col-md-3 control-label" style="width:100px;margin-left: 20px;">性别：</label>
					<div class="col-md-2">
						<select id="sex" name="sex" class="easyui-combobox" style="width: 180px;height:26px;" readonly="readonly" required editable="false" panelHeight="auto">
					
							<option value="0">男</option>
							<option value="1">女</option>
						</select>
					</div>
					<div class="col-md-3" id="sexErr">
						<label class="error"></label>
					</div>
				</div>
				<div class="form-group" style="width: 420px;float: left;">
					<label for="serFee" class="col-md-3 control-label" style="width:100px;margin-left: 20px;">服务费率：</label>
					<div class="col-md-6">
						<select id="serFee" name="serFee" class="easyui-combobox" style="width: 180px;height:26px;" readonly="readonly" required editable="false" panelHeight="auto">
							<option value="21">0.21(个人)</option>
							<option value="30">0.30(优惠)</option>
							<option value="38">0.38(基础)</option>
							<option value="50">0.50(上浮)</option>
						</select>
					</div>
					<div class="col-md-2" id="serFeeErr">
						<label class="error">%</label>
					</div>
				</div>
				<div class="form-group">
					<label for="usageq" class="col-md-3 control-label" style="width:100px;margin-left: 20px;">用途：</label>
					<div class="col-md-2">
						<input id="usageq" name="usageq"
							class="form-control isRemove" style="width: 570px;height:26px;" type="text"
							value="" maxlength="11" readonly="readonly" required/>
					</div>
					<div class="col-md-3" id="usageErr">
						<label class="error"></label>
					</div>
				</div>
				<div class="form-group" style="width: 420px;float: left;">
					<label for="expAmount" class="col-md-3 control-label" style="width:100px;margin-left: 20px;">*拟借款金额：</label>
					<div class="col-md-2">
						<input id="expAmount" name="expAmount"
							class="form-control isRemove" style="width: 180px;height:26px;" type="text"
							value="" maxlength="11" readonly="readonly" required/>
					</div>
					<div class="col-md-3" id="expAmountErr">
						<label class="error"> </label>
					</div>
				</div>
				<div class="form-group" style="width: 420px;float: left;">
					<label for="expCyc" class="col-md-3 control-label" style="width:100px;margin-left: 20px;">*拟借款期数：</label>
					<div class="col-md-2">
						<input id="expCyc" name="expCyc"
							class="form-control isRemove" style="width: 180px;height:26px;" type="text"
							value="" maxlength="11" readonly="readonly" required/>
					</div>
					<div class="col-md-3" id="expCycErr">
						<label class="error"></label>
					</div>
				</div>
				<div class="form-group">
					<label for="expDate" class="col-md-3 control-label" style="width:100px;margin-left: 20px;">*拟借款日期：</label>
					<div class="col-md-2">
						<input id="expDate" name="expDate"
							class="form-control isRemove" style="width: 180px;height:26px;" type="text"
							value="" maxlength="11" onchange="removeDate()" required readonly/>
					</div>
					<div class="col-md-3" id="expDateErr">
						<label class="error"></label>
					</div>
				</div>
				<div class="form-group">
					<label for="idCardBtn" class="col-md-3 control-label"
						style="width:100px;margin-left: 20px;">*身份证：</label>
					<div class="col-md-8">
						<span style="font-family:'Applied Font Regular', 'Applied Font';text-decoration:underline;">查看附件</span>
						<input id="photoOfIdCard" name="photoOfIdCard" type="hidden" value="">
						<input type='hidden' id='fileId' name='fileId'/>
					</div>
					<div class="col-md-2"></div>
				</div>
				<div class="form-group" id="lvyueDiv" class="lvyueDivClazz">
					<label for="" class="col-md-3 control-label"
						style="width:100px;margin-left: 20px;">*履约合同：</label>
				</div>
				
				<div id="lvyueDivAdd" class="lvyueDivClazz">
				
				</div>
				
				<div class="form-group" id="qitaDiv" class="qitaDivClazz">
					<label for="" class="col-md-3 control-label"
						style="width:100px;margin-left: 20px;">其他附件：</label>
		
				</div>
				<div id="qitaDivAdd" class="qitaDivClazz">
						
				</div>
				<div class="form-group">
					<label for="" class="col-md-3 control-label"
						style="width:100px;margin-left: 20px;">合同备注:</label>
					<div class="col-md-6">
						<textarea id="memo" name="memo" readonly="readonly" class="easyui-validatebox form-control easyui-textarea" rows=5 style="width:570px"></textarea>
					</div>
				</div>
				<!-- 保存按钮 -->
				<hr style="width: 98%;">
				<div class="form-group">
					<div class="col-md-3"></div>
					<a href="#" class="easyui-linkbutton button" iconcls="icon-ok"
						onclick="javascript:deletes()" id="">删除</a>
					<a href="#" class="easyui-linkbutton button" iconcls="icon-ok"
						 id="">取消</a>
				</div>
			</form>
		</div>
	</div>
	<script type="text/javascript">
	var xmluse;
	var mess;
	$(function(){
		$("#expDate").datetimepicker({
			format: 'yyyy-mm-dd',
			autoclose: true,
			language: "zh-CN",
			minView : 2,
		});
	});

	//页面加载事件
	function loadMsg(id){debugger
		$.ajax({
			url:'${ctx}/contract/get',
			data:{'id':id},
			async:true,
			success:function(data){debugger
				var flag = true;//填充上面数据
				var flag1  = true;//填充履约合同
				var flag2  = true;//填充其他附件
				
				var j = 1;//其他附件
				var i = 1;//所有文件
				$.each(data,function(index,value){
					if(flag){
						$("#id").val(data[0].id);
						$("#customerId").val(data[0].customerId);
						$("#contractId").val(data[0].contractId);
						$("#customerPhone").val(data[0].customerPhone);
						$("#customerName").val(data[0].customerName);
						$("#registerAdd").val(data[0].registerAdd);
						$("#perAdd").val(data[0].perAdd);
						$("#cardId").val(data[0].cardId);
						$("#emerContact").val(data[0].emerContact);
						$("#origin").val(data[0].emerContact);
						$("#marriage").combobox('setValue', data[0].marriage);
						$("#sex").combobox('setValue',data[0].sex);
						$("#serFee").combobox('select', data[0].serFee);
						
						$("#usage").val(data[0].usageq);
						$("#expAmount").val(data[0].expAmount);
						$("#expCyc").val(data[0].expCyc);
						$("#expDate").val(data[0].expDate);
						$("#status").val(data[0].status);
						$("#memo").val(data[0].memo);
						$("#firInsReason").val(data[0].firInsReason);
						$("#secInsReason").val(data[0].secInsReason);
						flag = false;
					}
					//下面设置图片
					//身份证
					if(data[index].fileType == "1"){
						$("#idCardSpan").text(data[index].fileAdd.substring(8));
						$("#photoOfIdCard").val(data[index].fileAdd);
						$("#fileId").val(data[index].customerId);
					}
					debugger
					//履约
					if(data[index].fileType == "2"){
						var str = "<div class='col-md-3'><span style=\"font-family:'Applied Font Regular', 'Applied Font';text-decoration:underline;\">查看附件"+(i++)+"</span></div>";
						if(flag1){//第一次加载到跟"标题同行"
							$('#lvyueDiv').append(str);
							//填充数据
							$("#lvyueContract"+i).val(data[index].fileAdd);//文件名
							if(i%4==0){
								//第一行加4个
								flag1 = false;
							}
						}else{
							$('#lvyueDivAdd').append("<div class='form-group'>"
									+"<label for='' class='col-md-3 control-label' style='width:100px;margin-left: 20px;'></label>"
									+str+"</div>");
							//填充数据
							$("#lvyueContract"+i).val(data[index].fileAdd);//文件名
						}
					}
					debugger
					//其他
					if(data[index].fileType == "9"){
						var str = "<div class='col-md-3'><span style=\"font-family:'Applied Font Regular', 'Applied Font';text-decoration:underline;\">查看附件"+(j++)+"</span></div>";
						if(flag2){//第一次加载到跟"标题同行"
							$('#qitaDiv').append(str);
							//填充数据
							$("#qitaContract"+j).val(data[index].fileAdd);//文件名
							$("#qtfjName"+j).val(data[index].attachName);
							if(i%4==0){
								//第一行加4个
								flag1 = false;
							}
						}else{
							$('#qitaDivAdd').append("<div class='form-group'>"
									+"<label for='' class='col-md-3 control-label' style='width:100px;margin-left: 20px;'></label>"
									+str+"</div>");
							//填充数据
							$("#qitaContract"+j).val(data[index].fileAdd);//文件名
							$("#qtfjName"+j).val(data[index].attachName);
						}
					}
				});
			}
		});	
	}
	function deletes(status){
		window.location.href="${ctx}/contract/delContract?id="+$("#contractId").val();
		
	}
	</script>
</body>
</html>